package logic

import (
	"context"
	"wet/wetrpc/wetrpcclient"

	"wet/api/internal/svc"
	"wet/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateShopLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCreateShopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateShopLogic {
	return &CreateShopLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CreateShopLogic) CreateShop(req *types.CreateShopRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	createShop, err := l.svcCtx.WetRpc.CreateShop(l.ctx, &wetrpcclient.CreateShopShopAddRequest{
		UserId: req.UserId,
		ShopId: req.ShopId,
		Num:    req.Num,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    500,
			Code:    nil,
		}, nil
	}
	return &types.Response{
		Message: "购物车添加成功",
		Data:    200,
		Code:    createShop,
	}, nil

}
